import http from '../../utils/http'
import type {ApiResponse, PageResult} from '../../utils/ApiResponse'
import {PagePermission, Permission} from "./types/permission.dto.ts";

export const addPermission = (data: Permission): Promise<ApiResponse<Object>> => {
    return http.post('/sysPermission/save', data)
}

export const deletePermissionById = (id: number): Promise<ApiResponse<Object>> => {
    return http.delete(`/sysPermission/delete/${id}`)
}

export const savePermissionInfo = (data: Permission): Promise<ApiResponse<Object>> => {
    return http.put('/sysPermission/save', data)
}

export const getAllPermissions = (data: PagePermission): Promise<PageResult<Object>> => {
    return http.get('/sysPermission/info', {
        params: {
            page: data.page,
            limit: data.limit,
            description: data.description
        }
    })
}

export const getPermissionInfoById = (id: number): Promise<ApiResponse<Permission>> => {
    return http.get(`/sysPermission/info/${id}`)
}